<?php
/**
 * 用户列表页
 * @author Wilton Wang <support@hangyutech.com>
 * @author QQ:858794040
 * @link http://iris.hangyutech.com 2016-01-19 14:41:18
 * @copyright  Iris/Yii2/adminLTE
 */
/* @var $this yii\web\View */
use yii\widgets\LinkPager;

$this->title = '模型列表';
?>
<!-- 内容区 -->

<div class="box">
	<!-- /.box-header -->
	<div class="box-body">
		<p><button type="button" class="btn bg-olive margin" onclick="LayerShow (this,0,'Model_Row_Status()','添加模型','#Model_Row_Status','<?php
								//逐个对给弹出框的元素赋值
								$layer_data = array(
									"t"=>'1',  //  内容取值的来源是从TD来动态取0   还是从此处赋值1
									"v"=> array(
										"status" => '',
										"title" => '',
										),
									);
								echo urlencode(json_encode($layer_data));
								?>')">添加新模型</button></p>
		<table id="Model_List" class="table table-bordered table-striped">
			<thead>
				<tr>
					<th>ID</th>
					<th>模型名</th>
					<th>状态</th>
					<th>更新时间</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<?php if (empty($rows)) {
					echo "<tr ><td colspan=4>无内容</td></tr>";
				} else {
					foreach($rows as $k =>$v)
						{?>
					<tr data-i="<?=$v['id'] ?>" <?php
					//把值缓存到标签中提供给AJAX
					foreach ($v as $m => $n) {
							echo "data-".$m."=\"".$n."\"";
						}
					?>>
						<td><?=$v['id'] ?></td>
						<td><?=$v['title'] ?></td>
						<td> <?php  if ($v['status']) {echo "使用中";}else{echo "禁用";} ?></td>
						<td> <?= date('Y-m-d',$v['updated_at']) ?></td>
						<td>
							<button type="button" class="btn btn-info" onclick="javascript:window.location.href='?r=model/fields'">详情</button>

							<button type="button" class="btn btn-info"  onclick="LayerShow (this,<?=$v['id'] ?>,'Model_Row_Status()','修改模型','#Model_Row_Status','<?php
								//逐个对给弹出框的元素赋值
								$layer_data = array(
									"t"=>'0',  //  内容取值的来源是从TD来动态取0   还是从此处赋值1
									"v"=> array(
										"status" => '',
										"title" => '',
										),
									);
								echo urlencode(json_encode($layer_data));
								?>')">修改</button>
							</td>
						</tr>
						<?php } }?>

					</tbody>
				</table>
				<div id="pages">
					<?= LinkPager::widget(['pagination' => $pages]); ?>
				</div>
			</div>


			<!-- 提示层内容 -->
			<div class="layerhidden" id="Model_Row_Status">
				<form class="form-horizontal">
					<div class="box-body">
						<div class="form-group">
							<label for="title" class="col-sm-2 control-label">标题：</label>

							<div class="col-sm-10">
								<input type="text" class="form-control" id="title" name="title" placeholder="请填入标题">
							</div>
						</div>
						<div class="form-group">
							<label for="status" class="col-sm-2 control-label">状态：</label>

							<div class="col-sm-10">

								<input type="Radio" name="status" value="1" id="status_0"> 启用
								<input type="Radio" name="status" value="0" id="status_1"> 禁用
							</div>
						</div>
					</div>
				</form>
			</div>


			<!-- /.box-body -->
		</div>
